package com.bafa.front.admin;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bafa.dbcache.LeagueCache;
import com.bafa.exceptions.ErrorException;
import com.bafa.objects.*;
import com.bafa.services.RetrieveServices;
import com.bafa.services.SeasonServices;

import javax.servlet.http.HttpSession;

public class CreateSeasonServlet extends AdminServlet {

	
	@Override
	public void doAdminEvent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, ErrorException {
		HttpSession session = request.getSession();
                SeasonTemp seasonTemp = new SeasonTemp();
                seasonTemp.setSeasonName(request.getParameter("season"));
                seasonTemp.setCupLeague(request.getParameter("cupLeague"));
                seasonTemp.setYear(new Integer(request.getParameter("year")).intValue());
                session.setAttribute("CREATEDSEASON",seasonTemp);
		request.setAttribute("TEAMS",RetrieveServices.getAllTeams());
		message = new Message();
		message.addMessage("Season Successfully Created");
		PageBean pageBeanTemp = (PageBean)LeagueCache.getPages().get("createseason");
		pageBean = new PageBean(pageBeanTemp);
	}
}
